<?php
$this->layout('head');

//
function generateTagSizeArray($tags, $smallest = 14, $largest = 44)
{
    if (empty($tags))
        return array();
    $counts = array();
    foreach ($tags as $tag)
        $counts[$tag['id']] = (int)$tag['counts'];
    $minCount = min($counts);
    $spread = max($counts) - $minCount;
    if ($spread <= 0)
        $spread = 1;
    $fontSpread = $largest - $smallest;
    if ($fontSpread <= 0)
        $fontSpread = 1;
    $fontStep = $fontSpread / $spread;
    foreach ($counts as $id => $val)
        $counts[$id] = ceil($smallest + ($val - $minCount) * $fontStep);
    return $counts;
}
$tagSize = generateTagSizeArray($this->tags);
?>
        <div id="tags">
        <?foreach ($this->tags as $tag):?>
        <a class="tag" title="<?=($tag['counts'] . _('个条目'))?>" href="/tag/name/<?=urlencode($tag['tag'])?>" style="font-size:<?=$tagSize[$tag['id']]?>px!important;"><?=$tag['tag']?></a>
        <?endforeach;?>
        </div>
<?php $this->layout('foot');?>
